package StudyCode.summary.mycollection;

import java.util.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ComputesTheArrayOfElementIndices {
	public static void main(String[] argv) {
		Collection smallCollection = Arrays.asList("1", "2");
		Collection bigCollection = Arrays.asList("科技与人文", "www.tah1986.com");
		System.out.println(Arrays.toString(computeDifferenceIndices(smallCollection, bigCollection)));
	}


	private static int[] computeDifferenceIndices(
			Collection<?> smallCollection, Collection<?> bigCollection) {
		List<Integer> addedIndices = new ArrayList<>();
		int index = 0;
		for (Iterator<?> ite = bigCollection.iterator(); ite.hasNext(); index++) {
			if (smallCollection == null
					|| !smallCollection.contains(ite.next())) {
				if (smallCollection == null) {
					ite.next();
				}
				addedIndices.add(index);
			}
		}
		int[] result = new int[addedIndices.size()];
		for (int i = 0; i < addedIndices.size(); i++) {
			result[i] = addedIndices.get(i);
		}
		return result;
	}
}
